package com.mer.controller;

import com.mer.entity.Teacher;
import com.mer.service.TeacherService;
import com.mer.vo.CommonResult;
import com.mer.vo.NewLecturerVo;
import com.mer.vo.TeacherVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: IIPhase-project
 * @description: 教师控制层
 * @author: 张庆恒
 * @create: 2021-10-19 14:03
 **/
@RestController
@RequestMapping("/core/teacher")
@Api(tags = "教师管理-教师列表")
public class TeacherController {
    @Resource
    private TeacherService teacherService;

    @PostMapping("/findTeacher/{page}/{limit}")
    @ApiOperation("分页查询全部教师")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页数"),
            @ApiImplicitParam(name = "limit", value = "每页条数")
    })
    public CommonResult findTeacherAll(
            @PathVariable("page") Integer page,
            @PathVariable("limit") Integer limit,
            @RequestBody TeacherVo teacherVo
    ) {
        return teacherService.findTeacherAll(page, limit, teacherVo);
    }

    @PostMapping("/changeTeacherStatus")
    @ApiOperation("修改教师状态")
    public CommonResult changeTeacherStatus(@RequestBody TeacherVo teacherVo) {
        return teacherService.changeTeacherStatus(teacherVo);
    }

    @PostMapping("/updateTeacherInfo")
    @ApiOperation("修改教师教师信息")
    public CommonResult updateTeacherInfo(@RequestBody TeacherVo teacherVo) {
        return teacherService.updateTeacherInfo(teacherVo);
    }

    @PostMapping("/NewLecturer")
    @ApiOperation("新增讲师")
    public CommonResult NewLecturer(NewLecturerVo newLecturerVo) {
        return teacherService.addTeacher(newLecturerVo);
    }

}
